<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>目的地 - 旅行家</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        body {
            font-family: Arial, sans-serif;
            max-width: 1000px;
            margin: 0 auto;
            padding: 20px;
            background-color: #f5f5f5;
        }
        h1 {
            color: #2c3e50;
            text-align: center;
            margin-bottom: 30px;
        }
        .search-container {
            display: flex;
            margin-bottom: 25px;
        }
        .search-input {
            flex-grow: 1;
            padding: 12px;
            border: 1px solid #ddd;
            border-radius: 4px 0 0 4px;
            font-size: 16px;
        }
        .search-button {
            padding: 12px 20px;
            background-color: #3498db;
            color: white;
            border: none;
            border-radius: 0 4px 4px 0;
            cursor: pointer;
            font-size: 16px;
        }
        .search-button:hover {
            background-color: #2980b9;
        }
        .filters {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
            margin-bottom: 25px;
            justify-content: center;
        }
        .filter {
            padding: 10px 20px;
            background-color: #f1f1f1;
            border: none;
            border-radius: 20px;
            cursor: pointer;
            font-size: 14px;
            transition: all 0.3s;
        }
        .filter:hover {
            background-color: #3498db;
            color: white;
        }
        .filter.active {
            background-color: #3498db;
            color: white;
        }
        .destinations {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
            gap: 25px;
        }
        .destination-card {
            border: 1px solid #ddd;
            border-radius: 10px;
            overflow: hidden;
            background-color: white;
            transition: transform 0.3s, box-shadow 0.3s;
        }
        .destination-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 20px rgba(0,0,0,0.1);
        }
        .destination-image {
            height: 180px;
            background-color: #eee;
            background-size: cover;
            background-position: center;
        }
        .destination-info {
            padding: 15px;
        }
        .destination-name {
            font-weight: bold;
            margin-bottom: 8px;
            font-size: 18px;
            color: #2c3e50;
        }
        .destination-location {
            color: #7f8c8d;
            margin-bottom: 8px;
            font-size: 14px;
        }
        .destination-details {
            font-size: 0.9em;
            color: #666;
            display: flex;
            justify-content: space-between;
        }
        .no-results {
            text-align: center;
            padding: 50px;
            color: #7f8c8d;
            grid-column: 1 / -1;
        }
    </style>
</head>
<body>
<h1>探索世界目的地</h1>

<div class="search-container">
    <input type="text" class="search-input" placeholder="搜索目的地...">
    <button class="search-button">搜索</button>
</div>

<div class="filters">
    <button class="filter active" data-region="all">全部</button>
    <button class="filter" data-region="asia">亚洲</button>
    <button class="filter" data-region="europe">欧洲</button>
    <button class="filter" data-region="america">美洲</button>
    <button class="filter" data-region="africa">非洲</button>
    <button class="filter" data-region="oceania">大洋洲</button>
</div>

<div class="destinations" id="destinations-container">
    <!-- 全部目的地将通过JavaScript动态加载 -->
</div>

<script>
    // 目的地数据
    const destinations = {
        all: [
            { name: "中国北京", location: "中国", season: "春秋最佳", price: "¥¥¥", region: "asia", image: 'img/tam.jpg' },
            { name: "日本东京", location: "日本", season: "春季最佳", price: "¥¥¥¥", region: "asia", image: "img/rbdj.jpg" },
            { name: "法国巴黎", location: "法国", season: "全年适宜", price: "¥¥¥¥", region: "europe", image: "img/fgbl.jpg" },
            { name: "印尼巴厘岛", location: "印尼", season: "夏季避暑", price: "¥¥", region: "asia", image: "img/ynbld.jpg" },
            { name: "中国上海", location: "中国", season: "春秋最佳", price: "¥¥¥", region: "asia", image: "img/zgsh.jpg" },
            { name: "日本京都", location: "日本", season: "春秋最佳", price: "¥¥¥¥", region: "asia", image: "img/rbjd.jpg" },
            { name: "泰国曼谷", location: "泰国", season: "冬季最佳", price: "¥¥", region: "asia", image: "img/tgmg.jpg" },
            { name: "马来西亚吉隆坡", location: "马来西亚", season: "全年适宜", price: "¥¥", region: "asia", image: "img/mlxyjlp.png" },
            { name: "西班牙阿尔罕布拉宫", location: "西班牙", season: "春秋最佳", price: "¥¥¥", region: "europe", image: "img/xbyaehblg.jpg" },
            { name: "法国圣托里尼岛", location: "希腊", season: "夏季最佳", price: "¥¥¥¥", region: "europe", image: "img/fgstlnd.jpg" },
            { name: "瑞士日内瓦湖", location: "瑞士", season: "夏季最佳", price: "¥¥¥¥", region: "europe", image: "img/rsrnwh.jpg" },
            { name: "希腊雅典卫城", location: "希腊", season: "春秋最佳", price: "¥¥¥", region: "europe", image: "img/xlydwc.jpg" },
            { name: "厄瓜多尔安第斯山脉", location: "厄瓜多尔", season: "夏季最佳", price: "¥¥¥", region: "america", image: "img/egdeadssm.jpg" },
            { name: "美国夏威夷群岛", location: "美国", season: "全年适宜", price: "¥¥¥¥", region: "america", image: "img/mgxwyqd.jpg" },
            { name: "萨尔瓦多", location: "萨尔瓦多", season: "冬季最佳", price: "¥¥", region: "america", image: "img/sewd.jpg" },
            { name: "坦桑尼亚乞力马扎罗山", location: "坦桑尼亚", season: "旱季最佳", price: "¥¥¥", region: "africa", image: "img/tslyqlmzls.jpg" },
            { name: "纳米比亚纳米布沙漠", location: "纳米比亚", season: "冬季最佳", price: "¥¥¥", region: "africa", image: "img/nmbynmbsm.png" },
            { name: "南非开普敦", location: "南非", season: "春秋最佳", price: "¥¥¥", region: "africa", image: "img/nfkpg.jpg" },
            { name: "埃及金字塔", location: "埃及", season: "冬季最佳", price: "¥¥", region: "africa", image: "img/ajjzt.jpg" },
            { name: "澳大利亚大堡礁", location: "澳大利亚", season: "夏季最佳", price: "¥¥¥¥", region: "oceania", image: "img/adlydjb.jpg" },
            { name: "斐济岛", location: "斐济", season: "全年适宜", price: "¥¥¥", region: "oceania", image: "img/fjd.png" },
            { name: "新西兰", location: "新西兰", season: "夏季最佳", price: "¥¥¥¥", region: "oceania", image: "img/xxl.jpg" },
            { name: "瓦努阿图", location: "瓦努阿图", season: "旱季最佳", price: "¥¥", region: "oceania", image: "img/wnat.jpg" }
        ],
        asia: [],
        europe: [],
        america: [],
        africa: [],
        oceania: []
    };

    // 按地区分类目的地
    destinations.all.forEach(dest => {
        destinations[dest.region].push(dest);
    });

    // 渲染目的地卡片
    function renderDestinations(dests) {
        const container = document.getElementById('destinations-container');
        container.innerHTML = '';

        if (dests.length === 0) {
            container.innerHTML = '<div class="no-results">没有找到匹配的目的地</div>';
            return;
        }

        dests.forEach(dest => {
            const card = document.createElement('div');
            card.className = 'destination-card';
            card.innerHTML = `
                    <div class="destination-image" style="background-image: url('${dest.image}')"></div>
                    <div class="destination-info">
                        <div class="destination-name">${dest.name}</div>
                        <div class="destination-location">${dest.location}</div>
                        <div class="destination-details">
                            <span>${dest.season}</span>
                            <span>${dest.price}</span>
                        </div>
                    </div>
                `;
            container.appendChild(card);
        });
    }

    // 初始加载全部目的地
    renderDestinations(destinations.all);

    // 筛选功能
    document.querySelectorAll('.filter').forEach(button => {
        button.addEventListener('click', function() {
            document.querySelectorAll('.filter').forEach(btn => btn.classList.remove('active'));
            this.classList.add('active');

            const region = this.dataset.region;
            if (region === 'all') {
                renderDestinations(destinations.all);
            } else {
                renderDestinations(destinations[region]);
            }
        });
    });

    // 搜索功能
    document.querySelector('.search-button').addEventListener('click', function() {
        const searchTerm = document.querySelector('.search-input').value.toLowerCase();
        const activeFilter = document.querySelector('.filter.active').dataset.region;

        let searchIn = activeFilter === 'all' ? destinations.all : destinations[activeFilter];

        const results = searchIn.filter(dest =>
            dest.name.toLowerCase().includes(searchTerm) ||
            dest.location.toLowerCase().includes(searchTerm)
        );

        renderDestinations(results);
    });

    // 按回车键也可以搜索
    document.querySelector('.search-input').addEventListener('keyup', function(e) {
        if (e.key === 'Enter') {
            document.querySelector('.search-button').click();
        }
    });
</script>
</body>
</html>